# _*_ coding : utf-8 _*_
# @Time : 2023/8/26 22:50
# @Author : 寻梦
# @File : 15_解析_获取百度网站的百度一下
# @Project : code
import urllib.request

from lxml import etree

base_url="https://www.baidu.com"
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 SLBrowser/8.0.1.5162 SLBChan/30"
}

request=urllib.request.Request(url=base_url,headers=headers)

response=urllib.request.urlopen(request)

content=response.read().decode('utf8')

# 获取树对象
tree=etree.HTML(content)
res=tree.xpath('//input[@type="submit"]/@value')
print(res[0])